<template>
	<view class="bankCard">
		<view class="bankCard_box" v-if="isShow == false">
			储蓄卡
		</view>
		<view class="bankCard_box_2" v-else>
			<view class="col-1">
				{{bankCardData.bank_name}}
			</view>
			<view class="col-2">
				<text>储蓄卡</text>
				<text>{{bankCardData.bank_num}}</text>
			</view>
		</view>
		<view class="Feature-box" @click="toPages(1)" v-if="isShow == true">
			<i></i>
			<text>编辑银行卡</text>
		</view>
		<view class="Feature-box m" @click="toPages(0)" v-if="isShow == false">
			<i></i>
			<text>添加银行卡</text>
		</view>
	</view>
</template>

<script>
	import request from '@/api/request.js';
	export default {
		data(){
			return {
				isShow : false,
				bankCardData : {}
			}
		},
		onShow() {
			this.getBankCard();
		},
		methods : {
			// 跳转
			toPages(data){
				uni.navigateTo({
					url: `/pages/bankCard/add?edit=${data}&bankCardData=${JSON.stringify(this.bankCardData)}`
				});
			},
			// 获取银行卡信息
			async getBankCard(){
				uni.showLoading({
					title: '加载中'
				});
				let data = await request.post('/api/User/showCard');
				console.log('笑了',data);
				uni.hideLoading();
				if(data.code === 1){
					if(data.data.bank_num){
						this.isShow = true;
						this.bankCardData = data.data;
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.bankCard {
		padding: 20rpx;
		.bankCard_box {
			border-radius: 10rpx;
			height: 100rpx;
			background-color: white;
			padding: 20rpx 30rpx;
			color: #999999;
			font-size: 16rpx;
			margin-bottom: 20rpx;
		}
		.bankCard_box_2 {
			border-radius: 10rpx;
			height: 140rpx;
			background-color: white;
			padding: 20rpx 30rpx;
			margin-bottom: 20rpx;
			.col-1 {
				color: #212121;
				font-size: 32rpx;
				margin-bottom: 10rpx;
			}
			.col-2 {
				display: flex;
				justify-content: space-between;
				font-size: 20rpx;
				color: #999999;
			}
		}
		.Feature-box {
			width: 100%;
			height: 130rpx;
			background-color: white;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 10rpx;
			font-size: 28rpx
		}
		.m {
			margin-top: 40rpx;
		}
	}
</style>